package com.zixuan.sina.datasource;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;

import java.util.Map;

public class DataSource {
    public static void main(String[] args) {
//        https://weibo.com/ajax/feed/hottimeline?since_id=0&refresh=0&group_id=102803&containerid=102803&extparam=discover%7Cnew_feed&max_id=0&count=10
       Integer start=1;
       Integer pageSize=10;
        String url = "https://weibo.com/ajax/feed/hottimeline?since_id=0&refresh=0&group_id=102803&containerid=102803&extparam=discover%7Cnew_feed&max_id=1&count=10";
//        url =  String.format(url,start,pageSize);
//        System.out.println(url);
        String resultStr = HttpUtil.get(url);
//        System.out.println(resultStr);
        Map map = JSONUtil.toBean(resultStr, Map.class);
        JSONArray statuses = (JSONArray) map.get("statuses");
        Map statusesMap = statuses.getBean(0, Map.class);
//        System.out.println(statusesMap);
        String textRaw = (String) statusesMap.get("text_raw");
        System.out.println(textRaw);//content
        Map<String,String> user = (Map<String, String>) statusesMap.get("user");
        System.out.println("========================");
        System.out.println(user); //screen_name  ==>nickname
        System.out.println("========================");
    }
}
